package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.service.ApUserSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: heima-leadnews
 * @description: App用户搜索信息表 控制器
 * @author: ryp
 * @create: 2023-05-04 20:22
 **/
@RestController
@RequestMapping("/api/v1/history")
@Slf4j
public class ApUserSearchController {
    @Autowired
    private ApUserSearchService apUserSearchService;

    /**
     * 功能描述: 加载搜索记录列表
     * @return : com.heima.model.common.dtos.ResponseResult
     */
    @PostMapping("/load")
    public ResponseResult findUserSearch() {
        ResponseResult userSearch = apUserSearchService.findUserSearch();
        return userSearch;
    }

    /**
     * 功能描述: 删除搜索记录
     * @param dto
     * @return : com.heima.model.common.dtos.ResponseResult
     */
    @PostMapping("/del")
    public ResponseResult delUserSearch(@RequestBody HistorySearchDto dto) {
        return apUserSearchService.delUserSearch(dto);
    }
}
